/** @brief File containing the declaration of the basic hexagon grid.
 *
 * This file contains the declaration of a grid visualisation where the
 * cells are hexagons.
 *
 * @file HexagonRepresentation.hpp
 * @author Johan "Solo" Luisier
 * @date 2013/08/24
 */
#ifndef HEXAGONREPRESENTATION_HPP
#define HEXAGONREPRESENTATION_HPP

#include "RepresentationBase.hpp"

class GridBase;

/**
 * @brief The HexagonRepresentation class
 *
 * @author Johan "Solo" Luisier
 * @date 2013/08/24
 *
 * @class HexagonRepresentation "HexagonRepresentation.hpp" "UI/HexagonRepresentation.hpp"
 */
class HexagonRepresentation : public RepresentationBase
{
    Q_OBJECT
public:
    /** @brief Standard constructor.
     *
     * The constructor initialises the data members.
     *
     * @param[in] grid pointer on the grid instance.
     * @param[in] parent pointer on the parent object.
     */
    explicit HexagonRepresentation( GridBase* grid, QObject *parent = 0 );
    /** @brief Destructor, frees the allocated memory.
     */
    ~HexagonRepresentation();
    /** @brief Getter for the tile height.
     *
     * This method allows to access the tile height (in pixels, with standard
     * zoom).
     *
     * @return a const reference on TileDimension.
     */
    inline const qreal& tileHeight() const { return TileHeight; }
    /** @brief Getter for the tile width.
     *
     * This method allows to access the tile width (in pixels, with standard
     * zoom).
     *
     * @return a const reference on TileDimension.
     */
    const qreal& tileWidth() const { return TileWidth; }
    const QPointF& topLeft() const { return TopLeftPosition; }
    const QPointF& bottomRight() const { return BottomRightPosition; }

    void retrieveCell( const QPointF& pt );
protected:

    /** @brief Horizontal dimension of the rectangle containing the hexagon.
     */
    static const qreal TileWidth;
    /** @brief Vertical dimension of the rectangle containing the hexagon.
     */
    static const qreal TileHeight;
    /** @brief Fraction of the height of the helper rectangle where there are
     * three different tiles.
     *
     * This value is obtained by trigonometry.
     */
    static const qreal HeightFraction;

    /** @brief Position of the top left corner of the view.
     */
    QPointF TopLeftPosition;
    /** @brief Position of the bottom right corner of the view.
     */
    QPointF BottomRightPosition;
private:
    void setupTiles();
};

#endif // HEXAGONREPRESENTATION_HPP
